package com.estrend.redbird.utils

import java.util.Base64
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec

object HMacUtils {

    fun generateHmac(data: ByteArray, key: ByteArray, algorithm: String): String {
        val mac = Mac.getInstance(algorithm)
        val secretKey = SecretKeySpec(key, algorithm)
        mac.init(secretKey)
        val hmacBytes = mac.doFinal(data)
        return Base64.getEncoder().encodeToString(hmacBytes)
    }


    const val HMAC_SHA256 = "HmacSHA256"
    const val HMAC_SHA1 = "HmacSHA1"
    const val HMAC_MD5 = "HmacMD5"

}